﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        //
        // GlobalCookie Plugin by etherdream
        //
        var GlobalCookie = function () {

            function setDOMContentLoaded(cb) {
                if (window.addEventListener) {
                    window.addEventListener("DOMContentLoaded", cb, false);
                }
                else {
                    (function () {
                        try {
                            document.documentElement.doScroll("left");
                            cb();
                        }
                        catch (e) {
                            setTimeout(arguments.callee, 1);
                        }
                    })();
                }
            }

            function createSwf(src) {
                var id = 'F' + ~ ~(1e6 * Math.random());
                var box = document.createElement('div');
                box.innerHTML = window.ActiveXObject ?
			'<object id=' + id + ' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><param name=movie value=' + src + '></object>' :
			'<embed name=' + id + ' src=' + src + '></embed>';

                var fla = box.firstChild;
                fla.style.position = 'absolute';
                fla.style.top = '-999px';
                document.body.appendChild(fla);

                return fla;
            }

            window.FGCOOKIEREADY = function () {
                if (typeof GlobalCookie.onready == 'function')
                    GlobalCookie.onready();
            }

            var f;

            setDOMContentLoaded(function () {
                f = createSwf('/media/s.swf');
            });

            return {
                get: function (key) {
                    try {
                        return f.FGet(key);
                    } catch (e) { }
                },
                set: function (key, val) {
                    try {
                        f.FSet(key, val);
                    } catch (e) { }
                },
                del: function (key) {
                    try {
                        f.FDel(key);
                    } catch (e) { }
                },
                clear: function () {
                    try {
                        f.FClr();
                    } catch (e) { }
                }
            };
        } ();
    </script>
</head>
<body>
<textarea id="txt" style="width:400px; height:100px"></textarea>
<hr/>

<script>
    function Read() {
        txt.value = GlobalCookie.get('myname');
    }

    function Write() {
        GlobalCookie.set('myname', txt.value);
    }

    function Del() {
        GlobalCookie.del('myname');
        Read();
    }

    GlobalCookie.onready = function () {
        // can use now
        Read();

        document.getElementById('btnRead').disabled = false;
        document.getElementById('btnWrite').disabled = false;
        document.getElementById('btnDel').disabled = false;
    }
</script>

<button id="btnRead" disabled="disabled" onclick="Read()">Read</button>
<button id="btnWrite" disabled="disabled" onclick="Write()">Write</button>
<button id="btnDel" disabled="disabled" onclick="Del()">Del</button>
</body>
</html>
